﻿using System.Text.RegularExpressions;
using KagSharp.Util;

namespace KagSharp.Lexer
{
    public class Token
    {
    	private Position _Position;
    	public Position Position { get{return _Position;} private set{_Position = value;} }
        private TokenType _Type;
        public TokenType Type { get{return _Type;}private set{_Type = value;} }
        private string _Text;
        public string Text { get{return _Text;}private set{_Text=value;} }
        private object _Value;
        public object Value { get{return _Value;}private set{_Value = value;} }

        public Token(Position position, TokenType type, string text, object value)
        {
            Expect.NotNull(position, type, text);

            Position = position;
            Type = type;
            Text = text;
            Value = value;
        }

        public bool IsType(TokenType type) {return  Type == type;}

        public override string ToString() {return "(" + Type + ") " + Regex.Escape(Text) + " : " + Regex.Escape(Value.ToString()) + "";}
    }
}
